<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>社区管理系统 - 登录</title>
  <style>
    /* 基础样式重置 */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    }

    /* 整体布局 */
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
      padding: 20px;
    }

    /* 登录卡片 */
    .login-card {
      width: 100%;
      max-width: 420px;
      background: #ffffff;
      border-radius: 16px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
      overflow: hidden;
      transition: transform 0.3s ease;
    }

    .login-card:hover {
      transform: translateY(-5px);
    }

    /* 头部样式 */
    .card-header {
      background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
      color: white;
      text-align: center;
      padding: 30px 20px;
    }

    .card-header h2 {
      font-size: 1.8rem;
      font-weight: 600;
      margin-bottom: 5px;
    }

    /* 表单区域 */
    .card-body {
      padding: 30px;
    }

    /* 错误提示 */
    .error-message {
      background: #ffebee;
      color: #c62828;
      padding: 12px 15px;
      border-radius: 8px;
      margin-bottom: 20px;
      font-size: 0.9rem;
      display: flex;
      align-items: center;
    }

    .error-message::before {
      content: "!";
      display: inline-block;
      width: 20px;
      height: 20px;
      background: #c62828;
      color: white;
      border-radius: 50%;
      text-align: center;
      line-height: 20px;
      margin-right: 10px;
    }

    /* 表单组 */
    .form-group {
      margin-bottom: 24px;
      position: relative;
    }

    .form-group label {
      display: block;
      margin-bottom: 8px;
      font-weight: 500;
      color: #2d3748;
      font-size: 0.95rem;
    }

    /* 输入框样式 */
    .input-field {
      width: 100%;
      padding: 14px 15px;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      font-size: 1rem;
      transition: all 0.3s ease;
      background: #f8fafc;
    }

    .input-field:focus {
      outline: none;
      border-color: #4361ee;
      box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
      background: #ffffff;
    }

    /* 下拉选择框 */
    .select-field {
      width: 100%;
      padding: 14px 15px;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      font-size: 1rem;
      background: #f8fafc;
      appearance: none;
      background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
      background-repeat: no-repeat;
      background-position: right 15px center;
      background-size: 16px;
    }

    /* 按钮容器 */
    .button-container {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-top: 10px;
    }

    /* 主按钮 */
    .btn-primary {
      background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
      color: white;
      border: none;
      padding: 14px;
      border-radius: 8px;
      font-size: 1rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 6px rgba(66, 153, 225, 0.2);
    }

    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 7px 14px rgba(66, 153, 225, 0.3);
    }

    /* 次要按钮 */
    .btn-secondary {
      background: #ffffff;
      color: #4361ee;
      border: 1px solid #e2e8f0;
      padding: 14px;
      border-radius: 8px;
      font-size: 1rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;
    }

    .btn-secondary:hover {
      background: #f8fafc;
      border-color: #cbd5e0;
    }

    /* 底部链接 */
    .footer-links {
      text-align: center;
      margin-top: 20px;
      font-size: 0.9rem;
      color: #718096;
    }

    .footer-links a {
      color: #4361ee;
      text-decoration: none;
      transition: color 0.2s;
    }

    .footer-links a:hover {
      color: #3a0ca3;
      text-decoration: underline;
    }

    /* 响应式调整 */
    @media (max-width: 480px) {
      .login-card {
        border-radius: 12px;
      }

      .card-body {
        padding: 25px 20px;
      }

      .card-header {
        padding: 25px 15px;
      }
    }
  </style>
</head>

<body>
<div class="login-card">
  <div class="card-header">
    <h2>社区管理系统</h2>
    <p>欢迎回来，请登录您的账户</p>
  </div>

  <div class="card-body">
    <% if (request.getAttribute("error") != null) { %>
    <div class="error-message">
      <%= request.getAttribute("error") %>
    </div>
    <% } %>

    <form action="login" method="post">
      <div class="form-group">
        <label for="role">选择角色</label>
        <select class="select-field" id="role" name="role">
          <option value="admin">管理员</option>
          <option value="resident">居民</option>
        </select>
      </div>

      <div class="form-group">
        <label for="username">用户名</label>
        <input type="text" class="input-field" id="username" name="username"
               placeholder="请输入用户名" required>
      </div>

      <div class="form-group">
        <label for="password">密码</label>
        <input type="password" class="input-field" id="password" name="password"
               placeholder="请输入密码" required>
      </div>

      <div class="button-container">
        <button type="submit" class="btn-primary">登录</button>
        <a href="register.jsp">
          <button type="button" class="btn-secondary">注册新账户</button>
        </a>
      </div>
    </form>

    <div class="footer-links">
      <a href="#">忘记密码?</a> • <a href="#">帮助中心</a>
    </div>
  </div>
</div>
</body>
</html>